In the prior art, it is known from DE 10 2008 001 009 A1 to carry out a diagnosis of a function of one or more inlet and/or outlet valves which can be actuated in a variable fashion in an internal combustion engine with the following steps: determining a modulated pressure indication which makes available an indication about a pressure in an air system of the internal combustion engine, by means of a pressure profile model, wherein the pressure profile model describes a pressure profile of a fault-free internal combustion engine as a function of an operating point; providing an indication of the actual instantaneous pressure in the air system; acquiring a deviation variable, as a function of the modeled pressure indication and the indication of the actual pressure in the air system; detecting a fault in the functioning of the inlet valve and/or outlet valve as a function of the deviation variable.